// 记分牌的类
class ScorePanel {
    //记录分数和等级
    score = 0;
    level = 1;
    scoreEle: HTMLElement
    levelEle: HTMLElement

    maxLevel: number //限制最大等级
    upScore: number // 多少分去升一级

    constructor(maxLevel: number = 10, upScore: number = 10) {
        this.scoreEle = document.getElementById('score')!;
        this.levelEle = document.getElementById('level')!;
        this.maxLevel = maxLevel
        this.upScore = upScore
    }
    //设置增加分数的方法
    addScore() {
        //+''是为了把number类型变成string类型
        this.scoreEle.innerHTML = ++this.score + '';
        //判断分数 
        if (this.score % this.upScore === 0) {
            this.levelUp()
        }
    }

    //提升等级方法
    levelUp() {
        if (this.level < this.maxLevel) {
            this.levelEle.innerHTML = ++this.level + '';
        }
    }

}

export default ScorePanel